<?php
Loader::loadFile('config.php', "modules/FacebookConnect");
/**
 * initialise block
 * 
 * @author       Thapakorn Tantirattanapong
 */
function FacebookConnect_Fanpageblock_init()
{
  
}

/**
 * get information on block
 * 
 * @author       Thapakorn Tantirattanapong
 * @return       array       The block information
 */
function FacebookConnect_Fanpageblock_info()
{
    return array('text_type'      => 'Fanpage Block',
                 'module'         => 'FacebookConnect',
                 'text_type_long' => 'Fanpage Block!',
                 'allow_multiple' => true,
                 'form_content'   => false,
                 'form_refresh'   => false,
                 'show_preview'   => true);
}

/**
 * display block
 * 
 * @author       Thapakorn Tantirattanapong
 * @param        array       $blockinfo     a blockinfo structure
 * @return       output      the rendered bock
 */
function FacebookConnect_Fanpageblock_display($blockinfo)
{
    $modname  = 'FacebookConnect';
    $render = pnRender::getInstance($modname);
    
    $BaseURL = pnGetBaseURL();
    $render->assign('APP_ID',APP_ID);
    $render->assign('FANPAGE_ID',FANPAGE_ID);
    $render->assign('BaseURL',$BaseURL);
    $blockinfo['content'] = $render->fetch('block_Fanpage.htm');
    return themesideblock($blockinfo);
}


/**
 * modify block settings
 * 
 * @author       Thapakorn Tantirattanapong
 * @param        array       $blockinfo     a blockinfo structure
 * @return       output      the bock form
 */
function FacebookConnect_Fanpageblock_modify($blockinfo)
{
  $render = pnRender::getInstance('FacebookConnect');
  
	return $render->fetch('block_Fanpage_modify.htm');
}


/**
 * update block settings
 * 
 * @author       Thapakorn Tantirattanapong
 * @param        array       $blockinfo     a blockinfo structure
 * @return       $blockinfo  the modified blockinfo structure
 */
function FacebookConnect_Fanpageblock_update($blockinfo)
{
    // clear the block cache
    $pnRender = pnRender::getInstance('FacebookConnect');
    $pnRender->clear_cache('block_Fanpage.htm');
    
    return $blockinfo;
}
